CREATE OR REPLACE PROCEDURE proc_insert_project_info(p_phid IN NUMBER) 
AS 
BEGIN
    INSERT INTO crm3_advance_project(
        phid,
        user_djly,
        phid_org,
        user_tbdw,
        user_ejhylb,
        state,
        bill_no,
        project_name,
        user_bdmc,
        user_scqy,
        user_yelb,
        user_sccyllb,
        user_hylb, -- 13
        user_xmms,
        user_scfw,
        user_gzjb,
        phid_province,
        phid_city,
        phid_region,
        user_yzdw,
        user_yzdwssjt,
        user_tbsj,
        phid_tenpsn,
        user_tbfzrlxfs,
        g_situation,
        phid_tbpsn,
        bill_dt,
        ng_phid_cu,
        ng_phid_bp,
        ng_phid_org,
        ng_phid_ui_scheme,
        ng_phid_original,
        ng_orgid_original,
        ng_sv_search_key,
        ng_sd_search_key,
        ng_share_sign,
        qualifirequire,
        manage_mode,
        phid_company,
        phid_fsource,
        phid_tender,
        phid_country,
        project_address,
        phid_conmode,
        designsit,
        progress,
        istend,
        asr_flag,
        wf_flag,
        arc_flag,
        phid_app,
        app_status,
        level_code,
        print_count,
        bill_type,
        user_type,
        phid_schemeid,
        py,
        imp_info,
        ng_record_ver,
        creator,
        editor,
        cur_orgid,
        phid_sourcemid,
        item_resource,
        phid_tbocode,
        phid_compsn,
        isimport,
        list_filter_val,
        query_field1_val,
        query_field2_val,
        uimulti_config_id,
        phid_fi_ocode,
        project_org,
        ng_write_source,
        phid_bidding_agent_company,
        phid_supervision_company,
        phid_design_company,
        user_xmszd
    )
    SELECT
        seq_auto_phid_project_info_to_project_tb.nextval,
        p_phid,
        project.phid_org,
        project.phid_org,
        project.u_ejhylb,
        '0',
        project.bill_no,
        project.u_xmbmc,
        p_phid, 
        project.u_scqy,
        project.u_ywlb,
        project.u_sccyllb,
        NVL(project.u_hylb,	6870000000000679),
        project.u_xmms,
        project.u_scfw,
        project.u_gzjb,
        project.u_xmszd,
        project.u_xmszs,
        project.u_xmszx,
        project.u_yzdw,
        project.u_yzdwssjt,
        project.u_tbsj,
        project.u_gzfzr,
        project.u_gzfzrlxfs,
        project.u_xmjk,
        project.phid_fill_psn,
        project.ng_insert_dt,
        1,
        0,
        project.phid_org,
        0,
        0,
        0,
        10,
        1,
        5,
        '',
        '',
        0,
        0,
        0,
        1,
        '',
        0,
        '',
        '',
        0,
        0,
        0,
        0,
        6870000000000009,
        0,
        0,
        0,
        '',
        '',
        6870000000000033,
        '',
        '',
        7,
        6870000000000009,
        6870000000000009,
        1,
        0,
        '',
        1,
        0,
        2,
        '',
        '',
        '',
        '0',
        '',
        '',
        '',
        '',
        '',
        '',
        CASE
            WHEN project.u_sccyllb = 6870000000000085 THEN project.u_szgb
            ELSE NVL(sheng.provincename,'') || '-' || NVL(city.cityname,'') || '-' || NVL(qvxian.regionname,'')
        END
    FROM
        p_form_gzxmxx_m project
        left join fg3_region sheng on sheng.phid = project.u_xmszd
        left join fg3_region city on city.phid = project.u_xmszs
        left join fg3_region qvxian on qvxian.phid = project.u_xmszx
    WHERE
        project.phid = p_phid;
    
    COMMIT;
EXCEPTION 
    WHEN OTHERS THEN 
        DBMS_OUTPUT.PUT_LINE('插入失败，错误信息：' || SQLERRM);
        ROLLBACK;
        RAISE;
END proc_insert_project_info;



